package com.android.mediaremote;

public class Util 
{
	public static String getDurationString(int seconds) 
	{		
		//Calculate the seconds to display:  
	    int secondsCount = seconds %60;  
	    seconds -= secondsCount;  
	    //Calculate the minutes:  
	    long minutesCount = seconds / 60;  
	    long minutes = minutesCount % 60;  
	    minutesCount -= minutes;  
	    //Calculate the hours:  
	    long hoursCount = minutesCount / 60;

	    return twoDigitString(hoursCount) + " : " + twoDigitString(minutes) + " : " + twoDigitString(secondsCount);
	}

	private static String twoDigitString(int number) 
	{

	    if (number == 0) 
	    {
	        return "00";
	    }

	    if (number / 10 == 0) 
	    {
	        return "0" + number;
	    }

	    return String.valueOf(number);
	}
	
	private static String twoDigitString(long number) 
	{

	    if (number == 0.0) 
	    {
	        return "00";
	    }

	    if (number / 10 == 0.0) 
	    {
	        return "0" + number;
	    }

	    return String.valueOf(number);
	}
	
}
